\section{Controller Design}

\frame[t]{
  \frametitle{Outline}
  \tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide]
}

\subsection{Human-Inspired Control}

\frame {
  \frametitle{Experimental Setup}
  \begin{columns}[t]
    \begin{column}{.6\textwidth}
      Overview
      \begin{itemize}
      \item
        PhaseSpace Motion Capture System
      \item
        Operating space of $5 \times 5 \times 5$ $\mathrm{m}^3$
      \item
        9 human subjects
      \item
        12 trials per subject
      \item
        12 high-speed cameras
      \item
        19 sensors per subject
      \item
        480 frames/sec temporal resolution
      \item
        $\pm 1$ mm spatial resolution
      \end{itemize}
    \end{column}
    \begin{column}{.38\textwidth}
      \begin{figure}
        \includegraphics[width=.99\textwidth]{PhaseSpace-logo}
      \end{figure}
    \end{column}
  \end{columns}
}
\frame[t]{
  \frametitle{Running the Experiment}
  \vspace{-5mm}
  \begin{figure}
    \centering
    \caption{Experimental setup for PhaseSpace system:}
    \movie[width=0.80\textwidth,externalviewer]{\includegraphics[width=0.80\textwidth]{labeled_diagram}}{./movies/human_experiment.mp4}
  \end{figure}
}
\frame[t]{
  \frametitle{Diversity of Test Subjects}
  \input{subject_data}
}

\frame[t] {
  \frametitle{Characterizing Human Walking}
  Analysis of the data indicates that specific kinematic behaviors faithfully represent the human gaite for the model studied:
  \begin{itemize}
    \item
      Forward position of hip:
      \begin{align*}
        p_{hip}^{x} &= L_{c} \sin \q_{1} + L_{t} \sin (\q_{1} + \q_{2}),
      \end{align*}
    \item
      Non-stance leg slope:
      \begin{align*}
        m_{swl} &= \frac{p_{hip}^{x} - p_{nsf}^{x}}{p_{hip}^{z} - p_{nsf}^{z}},
      \end{align*}
    \item
      Torso absolute angle:
      \begin{align*}
        \theta_{T} = \q_{1} + \q_{2} + \q_{3},
      \end{align*}
    \item
      Stance knee angle: $\q_{2}$, and
    \item
      Non-stance knee angle: $\q_{5}$.
  \end{itemize}
}

\subsection{Canonical Walking Functions}
\frame[t]{
  \frametitle{Canonical Walking Functions}
  The following function, termed a {\em canonical walking function}, fits human kinematics data quite accurately:
  \begin{align}
    \tag{CWF}
    y(t) &= e^{-\zeta \omega_{n} t} (c_{1} \cos (\omega_{d} t) + c_{2} \sin (\omega_{d} t)) + \hat{g}\\
    \nonumber
    &= e^{-a_{3} t} (a_{1} \cos (a_{2} t) + a_{4} \sin (a_{2} t)) + a_{5}
  \end{align}
  where,
  \begin{itemize}
  \item
    $\zeta$ is the damping ratio,
  \item
    $\omega_{n}$, $\omega_{d}$ are the natural and damped natural frequencies, resp.,
  \item
    $c_{1}$ and $c_{2}$ are initial conditions,
  \item
    and $\hat{g}$ is from a particular solution (related to gravity).
  \end{itemize}
}

\frame[t]{
  \frametitle{Optimizing Canonical Walking Functions}
  An optimization problem may be introduced to obtain the parameters which minimize the least-squared error between the human data and a canonical walking function. These fits may be done for each output.\\\ \\

  For $K$ data points with time data $\tau[k]$ and kinematics output data $x[k]$ for $k \in [1, \ldots, K]$, we minimize a cost function:
  \begin{align*}
    \min_{\{a_{i}\}_{i=1}^{5}} \sum_{k=1}^{K} \left( y_{d}(\tau[k], \alpha_{1}, \ldots, \alpha_{5}) - x[k] \right)^{2}
  \end{align*}
  Finding the minimum cost results in the most humanlike walking possible for the function choice used.
}

\frame[t]{
  \frametitle{Healthy Human Walking}
  \vspace{-4mm}
  \begin{figure}
    \centering
    \caption{Distributions of human outputs for healthy walking:}
    \vspace{-4mm}
    \subfloat[Hip position]{
      \includegraphics[width=.32\textwidth]{human_outputs_1}
    }
    \subfloat[Non-stance leg slope]{
      \includegraphics[width=.32\textwidth]{human_outputs_2}
    }\\
    \vspace{-2mm}
    \subfloat[Stance knee angle]{
      \includegraphics[width=.32\textwidth]{human_outputs_3}
    }
    \subfloat[Non-stance knee angle]{
      \includegraphics[width=.32\textwidth]{human_outputs_4}
    }
  \end{figure}
}



\subsection{Controller Design}
\frame[t]{
  \frametitle{Controller Design Overview}
  {\bf Specifications:}
	\begin{itemize}
		\item {\bf Stability:} Walking along the trajectory without falling.
		\item {\bf Performance:} Disturbance rejection, walking as close as possible to the trajectory.
		\item {\bf Robustness:} with respect to different surfaces and parameter uncertainties (masses and lengths).
	\end{itemize}
	\vspace{5mm}
	{\bf Methods:}
	\begin{itemize}
		\item {\bf Gain Scheduling:} enables us to control a nonlinear system using a series of linear controllers.
		\item {\bf LQR:} gives us an optimal controller that minimizes a desired cost functional.
	\end{itemize}
}

\frame[t]{
  \frametitle{Design Methods}
  {\bf Gain Scheduling:}\\
	Prescribed trajectory
    $$\xi : \Z_{1}^{K} \times \R \to \R^{n}$$ \\
    Linearized coordinates
	\begin{align*}
    	\delta \xi_{k}(t) := x(t) - \xi_{k}(t).
	\end{align*}
	Scheduling index $k$ determined by hip position, i.e.,
    \begin{align*}
        \{k \in \Z_{1}^{k} : (x(t) - \xi_{\ell}(t)) = \min_{\ell} (x(t) - \xi_{\ell}(t))
    \end{align*}
	Linearized dynamic model
	\begin{align*}
    	\delta \dot{x}_{k}(t) &= A_{k} \delta x_{k}(t) + B_{k} u(t), &\quad \delta y(t) &= C_{k} \delta x(t) + D_{k} u(t),
    \end{align*}\\[-7mm]
    \begin{align*}
    	A_{k} = \pd{f}{x}(\xi_k), &\quad B_{k} = g(\xi_k), \quad C_{k} = \pd{y}{x},
	\end{align*}\\[-2mm]
	where $y$ represents human outputs.
}

\frame[t]{
  \frametitle{Design Methods}
  {\bf LQR:}
	\begin{align*}
	    \dot{x}(t) &= Ax(t) + Bu(t),\\
	    y(t) &= Cx(t) + Du(t),
	\end{align*}
	{\bf Cost functional:}
	\begin{align*}
	    J &= \int_{0}^{\infty} \! (x^{T}(t) Q x(t) + u^{T}(t) R u(t)) \ dt,
	\end{align*}
	with $Q = Q^{T}>0$, $R = R^{T}>0$. The control gain which minimizes this functional is given by:
	\begin{align*}
	    u(t) &= -G x (t),\\
	    G &= R^{-1} B^{T} K,
	\end{align*}
	where $K$ is the solution of the algebraic Riccati equation:
	\begin{align*}
	    -K A - A^{T} K - Q + K B R^{-1} B^{T} K &= 0.
	\end{align*}
}






%\begin{figure}
%  \centering
%  \caption{Eigenvalues from simulations:}
%  \includegraphics[width=.85\textwidth]{eigenvalues}
%\end{figure}

